package com.atguigu.gmall.user.controller.api;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.model.user.UserAddress;
import com.atguigu.gmall.user.service.UserAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/***
 * 用户地址表的controller层
 */
@RestController
@RequestMapping("/api/user")
public class ApiUserAddressController {

    @Autowired
    private UserAddressService userAddressService;

    /**
     * 查询用户的所有地址
     * @return
     */
    @GetMapping("/getUserAddress")
    public Result getUserAddress(){
        //调用业务层的方法
        List<UserAddress> userAddressList = userAddressService.listByUsername();

        //返回
        return Result.ok(userAddressList);
    }
}
